/************************************************************************/
// file		: OutputBuffer.cpp											//
// date		: 2013-5-11  17:20											//
// author	: hotlala8088@gmail.com										//                                          
/************************************************************************/
#include "OutputBuffer.h"
#include <ace/Message_Block.h>
OutputBuffer::OutputBuffer(size_t size)
:buffer_(NULL)
{
	buffer_ = new ACE_Message_Block(size);
}

OutputBuffer::OutputBuffer(ACE_Message_Block * buffer)
:buffer_(buffer){}

OutputBuffer::~OutputBuffer()
{
	//if( NULL != buffer_ )
	//	delete buffer_;
}

bool 
OutputBuffer::Next(void** data, int* size)
{
	*data = buffer_->wr_ptr();
	*size = buffer_->space();
	return true;
}

void 
OutputBuffer::BackUp(int count)
{
	//UNDO	
}

bool 
OutputBuffer::Skip(int count)
{
	if(count > buffer_->space()) 
		return false;
	buffer_->wr_ptr(count);
	return true;
}

::google::protobuf::int64 
OutputBuffer::ByteCount() const
{
	return buffer_->length();
}
